package com.version.manager.controller.shop;

import com.version.manager.controller.BaseController;
import com.version.manager.entity.Shop.userAddress;
import com.version.manager.model.Msg;
import com.version.manager.service.Shop.userAddressService;
import com.version.manager.util.QueryParam;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@Api(value = "userAddressController")
@RequestMapping("/api/shop/address")
public class userAddressController extends BaseController<userAddressService, userAddress> {
    @Autowired
    private userAddressService service;
    @PostMapping("save")
    @ResponseBody
    public Msg save(@RequestBody userAddress address) throws Exception {
        return service.saveOrUpdate(address);
    }

    @GetMapping("getAddress")
    @ResponseBody
    public Msg getAddress(String userId){
        Map<String,Object> map=new HashMap<>();
        map.put("userId",userId);
        QueryParam param=new QueryParam(map);
        List<userAddress> list=service.selectList(param);
        return Msg.success().addData(list);
    }
}
